package calao;

import java.io.IOException;

class LoginPage
extends HtmlPage
{

	static final String ALIAS_PARAM = "alias";
	static final String PASSWORD_PARAM = "passw";
	static final String LOCALE_PARAM = "locale";

	String msg;
	
	void writeHead()
	throws IOException
	{
		writeTitle(title());
		writeStyleSheetLink("login.css");
	}

	void writeBody()
	throws IOException
	{
		writeLoginPanel();
	}
	
	void writeLoginPanel()
	throws IOException
	{
		startDiv("calao-LoginPanel");
		{
			if (msg!=null) {
				startDiv("calao-LoginStatus");
				write(msg);
				endElement();
			}
			startForm(null, "post"); 
			{
				startCenteredTable();
				{
					startRow();
					{
						startCell();
						write(alias());
						endElement();
						startCell();
						writeInput("text", ALIAS_PARAM);
						endElement();
					}
					endElement();
					startRow();
					{
						startCell();
						write(password());
						endElement();
						startCell();
						writeInput("password", PASSWORD_PARAM);
						endElement();
					}
					endElement();
				}
				endElement();
				writeInput("submit", null, login());
			}
			endElement();
		}
		endElement();
	}

	String title()
	{
		return "Connexion à l'espace de travail";
	}

	String alias()
	{
		return "Identifiant";
	}

	String password()
	{
		return "Mot de passe";
	}

	String login()
	{
		return "Se connecter";
	}

	String loginFailed()
	{
		return "Identifiant ou mot de passe incorrect.";
	}
	
	void setMessage(String message)
	{
		this.msg = message;
	}

}
